<?php
// 获取购物车信息
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

$uid = $_SESSION['USERINFOS']['uid'];

$sql = "SELECT * FROM tb_cart_info LEFT JOIN tb_goods_info ON tb_goods_info.g_id = tb_cart_info.g_id WHERE tb_cart_info.uid = '".$uid."'";
$result = mysqli_query($conn, $sql);
if($result){
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_array($result)){
            echo"
            <tr>
                <th>".$row['g_name']."</th>
                <td>".$row['c_name']."</td>
                <td>".$row['c_address']."</td>
                <td>".$row['c_phone']."</td>
                <td>".$row['c_num']."</td>
                <td>".$row['c_date']."</td>
                <td><a href='php/del_cart.php?id=".$row[0]."'><button type='button' class='btn btn-outline-danger btnstyle'>删 除</button></a></td>
                <td><a href='u_show_cart_goods.php?id=".$row[0]."'><button type='button' class='btn btn-outline-success btnstyle'>去购买</button></a></td>
            </tr>
            ";
        }
    }else{
        echo"<tr><td colspan='8'>暂无购物车信息</td></tr>";
    }

}else{
    echo"<tr><td colspan='8'>查询购物车信息失败</td></tr>";
}